Repository navigation
fix(mcpx/settings): ParseBytes refuses negative and overflowing byte sizes (#1697) - #4092
Merged
Merged
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 36 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ParseBytesinpkgs/mcpx/internal/settings/value.gonow refuses negative results and magnitudes that do not fit in an int64, with an error naming the offending value (#1697). Refusing insideParseBytesprotects every caller —Validate/Normalizeat apply time (file/env/flag/preset/runtime) and the direct read-time callers (Set.Bytes, built-in defaults) — so a KindBytes setting can no longer be admitted at any layer with a value that panics a consumer (make([]byte, 0, -1):makeslice: cap out of range) or silently wraps to MinInt64.>= 2^63errors assize too large: "<value>".n < 0errors assize must not be negative: "<value>"(also catches float→int64 conversion fallout).Tests
New
TestParseBytesRefusesNegativeAndOverflowingSizes(registry_test.go):-1,-5MB,-1KiB,999999999999999999999999TB,9223372036854775808all error and name the value;0still parses;Validatefor a KindBytes setting refuses the same inputs and accepts16MB. Existing suffix table test (TestByteSizesAcceptBothDecimalAndBinarySuffixes) keeps passing.Laptop runs (pkgs/mcpx):
go test ./internal/settings/ -run 'TestParseBytes|TestByteSizes'— PASSgo test ./internal/cli/ ./internal/daemon/— PASSgo test ./internal/settings/— the same 5 failures as clean main (verified by running clean main side by side): TestEveryDocumentHasAChapter, TestEverySettingHasAnEffectProbeOrAnExemption, TestNoUndeclaredEnvRead, TestTheEnvironmentDocIsCurrent, TestTheScriptEnvironmentIsWhatTheCodeSets — all pre-existing, unrelated (named already by triage task 5537).Consumer audit (acceptance)
The two scanner sites (
internal/cli/client.go,internal/cli/opcmd.go) pass init cap and max tobufio.Scanner.Buffer, whose effective max is the larger of the two — no valid (non-negative) value can crash there; the negative cap was the only crash vector and is now refused at parse.http.MaxBytesReaderconsumers take whateverBytes()returns; with negatives unparseable, a stored value can no longer be negative through any validated path. No follow-up issue needed.Cross-repo
mcpx also lives in dezren39/nix; the port is tracked from #1697 per the fleet cross-repo rule (see the SET-REMAINDER note on #1697 if it does not land with this PR).
Queue task 4257 (triaged by task 5164; bug confirmed by tasks 1915/5537). Coordinate with #3521 before overlapping parser edits.
Need help on this PR? Tag
@codesmith-botwith what you need.